public class YW_DuckSimulator {

	public static void main(String[] args) {
		YW_DuckSimulator simulator = new YW_DuckSimulator();
		YW_AbstractDuckFactory duckFactory = new YW_CountingDuckFactory();
		simulator.simulate(duckFactory);
	}
 
	void simulate(YW_AbstractDuckFactory duckFactory)  {
		YW_Quackable yw_MallardDuck = duckFactory.createMallardDuck();
		YW_Quackable yw_RedheadDuck = duckFactory.createRedheadDuck();
		YW_Quackable yw_DuckCall = duckFactory.createDuckCall();
		YW_Quackable yw_RubberDuck =duckFactory.createRubberDuck();
		YW_Quackable yw_GooseDuck = new YW_GooseAdapter(new YW_Goose());
		
		System.out.println("\nMy Duck Simulator: With Abstract Factory : Demo4");	
		simulate(yw_MallardDuck);
		simulate(yw_RedheadDuck);
		simulate(yw_DuckCall);
		simulate(yw_RubberDuck);
		simulate(yw_GooseDuck);
		
		System.out.println("The my ducks quacked " + 
               YW_QuackCounter.getQuacks() + " times");
	}

	void simulate(YW_Quackable duck) {
		duck.quack();
	}
}
